from selenium import webdriver
import time

#driver = webdriver.Firefox()
#关闭每次google浏览器检测自动化脚本控制浏览器的设置页面
option = webdriver.ChromeOptions()
# google驱动所在的路径
option.add_argument("--user-data-dir=C:\\software\\python")
driver = webdriver.Chrome(options=option)

driver.get("https://www.baidu.com")

# 断言的信息
print(driver.current_url)
print(driver.title)
print(driver.page_source)

# 截取浏览器窗口并保存成图片
driver.get_screenshot_as_file("shot.png")


# 获取浏览器大小
print(driver.get_window_size())
# #等待3s
# time.sleep(3)
# # 设置浏览器为全屏
# driver.maximize_window()
# #等待3s
# time.sleep(3)
# print(driver.get_window_size())
# # 设置浏览器大小
# driver.set_window_size(400,400)

time.sleep(3)
#刷新
driver.refresh()
time.sleep(3)
driver.get("https://gitee.com/")
time.sleep(3)
#回退
driver.back()
time.sleep(3)
#前进
driver.forward()
time.sleep(3)
#关闭
driver.close()
